package com.cskaoyan.controller.backStage;

import com.cskaoyan.model.Collect;
import com.cskaoyan.model.bo.BaseParamBO;
import com.cskaoyan.model.vo.BaseRespVO;
import com.cskaoyan.model.vo.DataVO;
import com.cskaoyan.service.CollectService;
import com.cskaoyan.util.StringUtil;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @description：会员收藏
 * @author     ：huzhouming
 * @date       ：2022/5/6 11:31
 */
@RestController
@RequestMapping("admin/collect")
public class CollectController {
    @Autowired
    CollectService collectService;
    @RequiresPermissions("admin:collect:list")
    @GetMapping("list")
    /**
     * @author: huzhouming
     * @description: 查询会员信息
     * @date: 2022/5/6
     * @param paramBO
     * @param userId
     * @param valueId
     * @return com.cskaoyan.model.vo.BaseRespVO
     */
    public BaseRespVO list(BaseParamBO paramBO,String userId,String valueId){
        DataVO<Collect> dataVO;
        try {
            Integer i;
            Integer i2;
            if (StringUtil.isEmpty(userId)) {
                i = null;
            } else {
                i = Integer.parseInt(userId);
            }
            if (StringUtil.isEmpty(valueId)) {
                i2 = null;
            } else {
                i2 = Integer.parseInt(valueId);
            }
            dataVO = collectService.query(paramBO,i,i2);
        }catch (Exception e){
            return BaseRespVO.parameterError("参数值不对");
        }

        return BaseRespVO.ok(dataVO);
    }
}
